package com.junzhiit.nengji.app.web.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.app.service.WithdrawalHistoryService;
import com.junzhiit.nengji.app.web.util.aliyun.SmsUtil;
import com.junzhiit.nengji.app.web.vo.DataTablesParamVO;
import com.junzhiit.nengji.app.web.vo.OrdersDataHistoryVO;
import com.junzhiit.nengji.app.web.vo.ResultVO;
import com.junzhiit.nengji.app.web.vo.WithdrawalHistoryVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/withdrawal")
public class WithdrawalHistoryController extends BaseController{

	@Autowired
	private WithdrawalHistoryService withdrawalHistoryService;
	
	@ApiOperation(value = "获取所有提现记录")
	@RequestMapping(method = RequestMethod.GET)
	public Map<String, Object> findAll(DataTablesParamVO dtp,WithdrawalHistoryVO shopWithdrawalHistoryVO) {
		AssertUtil.notBlank(shopWithdrawalHistoryVO.getSessionId(), "sessionId is required.");
		return withdrawalHistoryService.findAll(dtp,shopWithdrawalHistoryVO);
	}
	
	@ApiOperation(value="获取手机验证码(申请提现)")
	@RequestMapping(value = "/get/mobile/phone/code", method = RequestMethod.GET)
	public ResultVO getMobilePhoneCode(String mobilePhone){
		AssertUtil.notBlank(mobilePhone, "mobile phone is required.");
		String smsModel=SmsUtil.ALIYUN_SMS_VALIDATION;
		return SmsUtil.sendPhoneCode(mobilePhone, smsModel);
	}
	
	@ApiOperation(value = "申请提现")
	@RequestMapping(value="/add",method = RequestMethod.POST)
	public ResultVO add(WithdrawalHistoryVO shopWithdrawalHistoryVO) {
		AssertUtil.notBlank(shopWithdrawalHistoryVO.getSessionId(), "sessionId is required.");
		return withdrawalHistoryService.insertHistory(shopWithdrawalHistoryVO);
	}
	
	@ApiOperation(value = "查询商户资产明细")
	@RequestMapping(value="/property/history",method = RequestMethod.GET)
	public Map<String, Object> getPropertyHistory(DataTablesParamVO dtp,OrdersDataHistoryVO ordersDataHistoryVO){
		AssertUtil.notBlank(ordersDataHistoryVO.getSessionId(), "sessionId is required.");
		return withdrawalHistoryService.findAll(dtp, ordersDataHistoryVO);
	}
	
	@ApiOperation(value = "商户点击订单历史数据查询相应商品")
	@RequestMapping(value="/property/goods/history",method = RequestMethod.GET)
	public ResultVO getPropertyGoodsHistory(String ordersDataHistoryId){
		return withdrawalHistoryService.shopFindGoods(ordersDataHistoryId);
	}
}